home *** CD-ROM | disk | FTP | other *** search
/ SGI Freeware 1999 August / SGI Freeware 1999 August.iso / dist / fw_perl.idb / usr / freeware / catman / p_man / cat3 / Tie::Array.Z / Tie::Array
Encoding:
Text File  |  1998-10-28  |  6.9 KB  |  265 lines

  1.  
  2.  
  3.  
  4.      TTTTiiiieeee::::::::AAAArrrrrrrraaaayyyy((((3333))))   22223333////JJJJuuuullll////99998888 ((((ppppeeeerrrrllll 5555....000000005555,,,, ppppaaaattttcccchhhh 00002222))))     TTTTiiiieeee::::::::AAAArrrrrrrraaaayyyy((((3333))))
  5.  
  6.  
  7.  
  8.      NNNNAAAAMMMMEEEE
  9.       Tie::Array - base class for tied arrays
  10.  
  11.      SSSSYYYYNNNNOOOOPPPPSSSSIIIISSSS
  12.           package NewArray;
  13.           use Tie::Array;
  14.           @ISA = ('Tie::Array');
  15.  
  16.           #    mandatory methods
  17.           sub TIEARRAY { ... }
  18.           sub FETCH    { ... }
  19.           sub FETCHSIZE { ... }
  20.  
  21.           sub STORE    { ... }           # mandatory if elements writeable
  22.           sub STORESIZE { ... }    # mandatory if elements can be added/deleted
  23.  
  24.           #    optional methods - for efficiency
  25.           sub CLEAR    { ... }
  26.           sub PUSH { ... }
  27.           sub POP {    ... }
  28.           sub SHIFT    { ... }
  29.           sub UNSHIFT { ...    }
  30.           sub SPLICE { ... }
  31.           sub EXTEND { ... }
  32.           sub DESTROY { ...    }
  33.  
  34.           package NewStdArray;
  35.           use Tie::Array;
  36.  
  37.           @ISA = ('Tie::StdArray');
  38.  
  39.           #    all methods provided by    default
  40.  
  41.           package main;
  42.  
  43.           $object =    tie @somearray,Tie::NewArray;
  44.           $object =    tie @somearray,Tie::StdArray;
  45.           $object =    tie @somearray,Tie::NewStdArray;
  46.  
  47.  
  48.      DDDDEEEESSSSCCCCRRRRIIIIPPPPTTTTIIIIOOOONNNN
  49.       This module provides methods for array-tying classes.    See
  50.       the _p_e_r_l_t_i_e manpage for a list of the    functions required in
  51.       order    to tie an array    to a package. The basic    TTTTiiiieeee::::::::AAAArrrrrrrraaaayyyy
  52.       package provides stub    DELETE and EXTEND methods, and
  53.       implementations of PUSH, POP,    SHIFT, UNSHIFT,    SPLICE and
  54.       CLEAR    in terms of basic FETCH, STORE,    FETCHSIZE, STORESIZE.
  55.  
  56.       The TTTTiiiieeee::::::::SSSSttttddddAAAArrrrrrrraaaayyyy package provides efficient methods
  57.       required for tied arrays which are implemented as blessed
  58.       references to    an "inner" perl    array.    It inherits from
  59.       TTTTiiiieeee::::::::AAAArrrrrrrraaaayyyy, and should cause tied arrays to behave exactly
  60.  
  61.  
  62.  
  63.      Page 1                        (printed 10/23/98)
  64.  
  65.  
  66.  
  67.  
  68.  
  69.  
  70.      TTTTiiiieeee::::::::AAAArrrrrrrraaaayyyy((((3333))))   22223333////JJJJuuuullll////99998888 ((((ppppeeeerrrrllll 5555....000000005555,,,, ppppaaaattttcccchhhh 00002222))))     TTTTiiiieeee::::::::AAAArrrrrrrraaaayyyy((((3333))))
  71.  
  72.  
  73.  
  74.       like standard    arrays,    allowing for selective overloading of
  75.       methods.
  76.  
  77.       For developers wishing to write their    own tied arrays, the
  78.       required methods are briefly defined below. See the the
  79.       _p_e_r_l_t_i_e manpage section for more detailed descriptive, as
  80.       well as example code:
  81.  
  82.       TIEARRAY classname, LIST
  83.            The class method    is invoked by the command tie @array,
  84.            classname. Associates an    array instance with the
  85.            specified class.    LIST would represent additional
  86.            arguments (along    the lines of the _A_n_y_D_B_M__F_i_l_e manpage
  87.            and compatriots)    needed to complete the association.
  88.            The method should return    an object of a class which
  89.            provides    the methods below.
  90.  
  91.       STORE    this, index, value
  92.            Store datum _v_a_l_u_e into _i_n_d_e_x for    the tied array
  93.            assoicated with object _t_h_i_s. If this makes the array
  94.            larger then class's mapping of undef should be returned
  95.            for new positions.
  96.  
  97.       FETCH    this, index
  98.            Retrieve    the datum in _i_n_d_e_x for the tied    array
  99.            assoicated with object _t_h_i_s.
  100.  
  101.       FETCHSIZE this
  102.            Returns the total number    of items in the    tied array
  103.            assoicated with object _t_h_i_s. (Equivalent    to
  104.            scalar(@array)).
  105.  
  106.       STORESIZE this, count
  107.            Sets the    total number of    items in the tied array
  108.            assoicated with object _t_h_i_s to be _c_o_u_n_t.    If this    makes
  109.            the array larger    then class's mapping of    undef should
  110.            be returned for new positions.  If the array becomes
  111.            smaller then entries beyond count should    be deleted.
  112.  
  113.       EXTEND this, count
  114.            Informative call    that array is likely to    grow to    have
  115.            _c_o_u_n_t entries.  Can be used to optimize allocation.
  116.            This method need    do nothing.
  117.  
  118.       CLEAR    this
  119.            Clear (remove, delete, ...) all values from the tied
  120.            array assoicated    with object _t_h_i_s.
  121.  
  122.       DESTROY this
  123.            Normal object destructor    method.
  124.  
  125.  
  126.  
  127.  
  128.  
  129.      Page 2                        (printed 10/23/98)
  130.  
  131.  
  132.  
  133.  
  134.  
  135.  
  136.      TTTTiiiieeee::::::::AAAArrrrrrrraaaayyyy((((3333))))   22223333////JJJJuuuullll////99998888 ((((ppppeeeerrrrllll 5555....000000005555,,,, ppppaaaattttcccchhhh 00002222))))     TTTTiiiieeee::::::::AAAArrrrrrrraaaayyyy((((3333))))
  137.  
  138.  
  139.  
  140.       PUSH this, LIST
  141.            Append elements of LIST to the array.
  142.  
  143.       POP this
  144.            Remove last element of the array    and return it.
  145.  
  146.       SHIFT    this
  147.            Remove the first    element    of the array (shifting other
  148.            elements    down) and return it.
  149.  
  150.       UNSHIFT this,    LIST
  151.            Insert LIST elements at the begining of the array,
  152.            moving existing elements    up to make room.
  153.  
  154.       SPLICE this, offset, length, LIST
  155.            Perform the equivalent of splice    on the array.
  156.  
  157.            _o_f_f_s_e_t is optional and defaults to zero,    negative
  158.            values count back from the end of the array.
  159.  
  160.            _l_e_n_g_t_h is optional and defaults to rest of the array.
  161.  
  162.            _L_I_S_T may    be empty.
  163.  
  164.            Returns a list of the original _l_e_n_g_t_h elements at
  165.            _o_f_f_s_e_t.
  166.  
  167.      CCCCAAAAVVVVEEEEAAAATTTTSSSS
  168.       There    is no support at present for tied @ISA.    There is a
  169.       potential conflict between magic entries needed to notice
  170.       setting of @ISA, and those needed to implement 'tie'.
  171.  
  172.       Very little consideration has    been given to the behaviour of
  173.       tied arrays when $[ is not default value of zero.
  174.  
  175.      AAAAUUUUTTTTHHHHOOOORRRR
  176.       Nick Ing-Simmons <nik@tiuk.ti.com>
  177.  
  178.  
  179.  
  180.  
  181.  
  182.  
  183.  
  184.  
  185.  
  186.  
  187.  
  188.  
  189.  
  190.  
  191.  
  192.  
  193.  
  194.  
  195.      Page 3                        (printed 10/23/98)
  196.  
  197.  
  198.  
  199.  
  200.  
  201.  
  202.      TTTTiiiieeee::::::::AAAArrrrrrrraaaayyyy((((3333))))   22223333////JJJJuuuullll////99998888 ((((ppppeeeerrrrllll 5555....000000005555,,,, ppppaaaattttcccchhhh 00002222))))     TTTTiiiieeee::::::::AAAArrrrrrrraaaayyyy((((3333))))
  203.  
  204.  
  205.  
  206.  
  207.  
  208.  
  209.  
  210.  
  211.  
  212.  
  213.  
  214.  
  215.  
  216.  
  217.  
  218.  
  219.  
  220.  
  221.  
  222.  
  223.  
  224.  
  225.  
  226.  
  227.  
  228.  
  229.  
  230.  
  231.  
  232.  
  233.  
  234.  
  235.  
  236.  
  237.  
  238.  
  239.  
  240.  
  241.  
  242.  
  243.  
  244.  
  245.  
  246.  
  247.  
  248.  
  249.  
  250.  
  251.  
  252.  
  253.  
  254.  
  255.  
  256.  
  257.  
  258.      Page 4                        (printed 10/23/98)
  259.  
  260.  
  261.  
  262.  
  263.  
  264.  
  265.